Rounding Numbers
- Rounds to the nearest integer. The original variable (scoreAvg) stays unchanged
var numberOfStars = Math.round(scoreAvg);
- Rounds to the nearest integer. The original variable (scoreAvg) is changed
scoreAvg = Math.round(scoreAvg);
- Rounds up the nearest integer, 1.
var scoreAvg = Math.ceil(.000001);
- Rounds down to the nearest integer, 0.
var scoreAvg = Math.floor(.999999);
- Rounds down to the nearest integer, 1.
var scoreAvg = Math.floor(1.9);